<admintpl file="header"/>
<body class="J_scroll_fixed">
<div class="wrap J_check_wrap">
  <ul class="nav nav-tabs">
     <li class="active"><a href="{:U('Statistics/index')}">用户列表</a></li>
     <li><a href="{:U('Statistics/source')}">来源统计</a></li>
     <li><a href="{:U('Statistics/month')}">月注册数</a></li>
     <li><a href="{:U('Statistics/day')}">日注册数</a></li>
  </ul>
  <style> 
	input .iduoxuan{ width:14px; height:20px;float: left;} 
	span .sduoxuan{ width:14px; height:14px;margin-right:30px;}
</style>
		<form class="well form-search" method="post" action="{:U('Statistics/index')}">
			<div class="search_type cc mb10">
				<div class="mb10">
					<span class="mr20">用户来源： 
	              	<select id="province"name="typeclass" class="normal_select index_select">  
			        		<option value="0">全部</option>
			        		<foreach name="type" item="vo">
			        			<if condition="$formpost['typeclass'] eq $vo['id']">
				        			<option selected="selected" value="{$vo.id}">{$vo.name}</option>
				        			<else />
				        			<option value="{$vo.id}">{$vo.name}</option>
			        			</if>
			            </foreach>
	               	</select>
	               	<input type="checkbox" name="old" value='0' class="iduoxuan" <if condition="$formpost['old'] eq '0'">checked="checked"</if> style="margin-top: -2px;"/>
	               	<span class="sduoxuan">查看旧版</span>
						用户ID：
						<input type="text" name="userid" value="{$formpost.userid}"  style="width: 80px;"> &nbsp; &nbsp;
						用户昵称：
						<input type="text" name="nickname" value="{$formpost.nickname}"  style="width: 80px;"> &nbsp; &nbsp;
						邀请码：
						<input type="text" name="code" value="{$formpost.code}"  style="width: 80px;"> &nbsp; &nbsp;
						手机号：
						<input type="text" name="telephone" value="{$formpost.telephone}"  style="width: 80px;"> &nbsp; &nbsp;
						注册日期：
						<input type="text" name="start_time" value="{$formpost.start_time}" class="J_date" style="width: 80px;">-
						<input type="text" name="end_time" value="{$formpost.end_time}" class="J_date" style="width: 80px;"> &nbsp; &nbsp;
						<input type="submit" class="btn btn-primary" value="搜索" />
						<if condition="$num neq 0">
							共有 {$num} 条相关记录
						</if>
					</span>
				</div>
			</div>
		</form>
   <div class="table_list">
      <div class="p10"><div class="pages"> {$Page} 
        <button class="btn btn-primary btn_submit mr10 J_articles_move" type="button">调整来源</button></div>
      </div>
   <table width="100%" cellspacing="0" class="table table-hover">
        <thead>
          <tr>
						<th width="15"><label><input type="checkbox" class="J_check_all" data-direction="x" data-checklist="J_check_x"></label></th>
            <th width="40">ID</th>
            <th>用户昵称</th>
            <th width="45">邀请码</th>
            <th width="45">来源码</th>
            <th width="40">性别</th>
            <th width="40">年龄</th>
            <th width="80">联系方式</th>
            <th>地址</th>
            <th>设备号</th>
            <th>用户来源</th>
            <th>注册日期</th>
            <th width="60">操作</th>
          </tr>
        </thead>
        <tbody>
        <foreach name="lists" item="vo">
          <tr>
			<td><input type="checkbox" class="J_check" data-yid="J_check_y" data-xid="J_check_x" name="ids[]" value="{$vo.id}" title="ID:{$vo.id}"></td>
            <td>{$vo.id}</td>
            <td class='emoji'>
									<php> 
										$base64 = $vo['nickname'];
								 	echo $base64 = preg_replace_callback ( '/@E(.{6}==)/', function ($r) {
													return base64_decode ( $r [1] );
											}, $base64 );
										$uid = $user['id'];
									</php>
            </td>
            <td>
			    		<foreach name="usercodes" item="codes">
								<if condition="$codes['relateduserid'] eq $vo['id']">
				        			{$codes.my_invite_code}
				    		</if>
			        </foreach>
            </td>
            <td>
			    		<foreach name="usercodes" item="codes">
								<if condition="$codes['relateduserid'] eq $vo['id']">
				        			{$codes.invite_me_code}
				    		</if>
			        </foreach>
            </td>
    		<foreach name="uinfo" item="info">
				<if condition="$info['relatedUserID'] eq $vo['id']">
					<php> $gender = 1;</php>
        			<td>{$info.gender}</td>
        			<td>{$info.age}</td>
        			<php>break;</php>
    		</if>
        </foreach>
						<if condition="$gender eq 0">
        			<td></td><td></td>
        		</if>
            <td>
		        <foreach name="contacts" item="contact">
					<if condition="$contact['userid'] eq $vo['id']">
	        				{$contact.telephone}
	        				<php>break;</php>
	        		</if>
		        </foreach>
            </td>
            <td>
		        <foreach name="contacts" item="contact">
							<if condition="$contact['userid'] eq $vo['id']">
							{$contact.street1}
							<php>break;</php>
							</if>
		        </foreach>
            </td>
            <td>{$vo.firstuniqueid}</td>
            <td>
				<php> $nosoure = $gender = 0;</php>
    		<foreach name="type" item="typeid">
					<if condition="$typeid['id'] eq substr($vo['regSource'],0,4) && $nosoure eq 0">
	        	{$typeid.name} — {$vo.regSource}
						<php> $nosoure = 1;break;</php>
	        </if>
       	</foreach>
    		<foreach name="type" item="typeid">
					<if condition="$typeid['id'] eq $vo['regSource'] && $nosoure eq 0">
						{$typeid.name} — {$vo.regSource}
						<php> $nosoure = 1;break;</php>
					</if>
        </foreach>
						<if condition="$nosoure eq 0">
        			未知来源 — {$vo.regSource}
        		</if>
            </td>
            <td>{$vo.created}</td>
					<td>
						<a href="{:U('Statistics/edit',array('id'=>$vo['id'],'p'=>$_GET['p'],'c'=>$formpost['typeclass']))}">修改</a>
						|
						<a href="{:U('Statistics/detailed',array('id'=>$vo['id']))}">详细</a>
					</td>
          </tr>
         </foreach>
        </tbody>
        <thead>
          <tr>
			<th width="15"><label><input type="checkbox" class="J_check_all" data-direction="x" data-checklist="J_check_x"></label></th>
            <th width="40">ID</th>
            <th>用户昵称</th>
            <th width="45">邀请码</th>
            <th width="45">来源码</th>
            <th width="40">性别</th>
            <th width="40">年龄</th>
            <th width="80">联系方式</th>
            <th>地址</th>
            <th>设备号</th>
            <th>用户来源</th>
            <th>注册日期</th>
            <th width="60">操作</th>
          </tr>
        </thead>
      </table>
      <div class="p10"><div class="pages"> {$Page} 
        <button class="btn btn-primary btn_submit mr10 J_articles_move" type="button">调整来源</button></div>
      </div>
   </div>
</div>
<script type="text/javascript" src="__ROOT__/statics/js/common.js"></script>
	<script>
		function refersh_window() {
			var refersh_time = getCookie('refersh_time');
			if (refersh_time == 1) {
				window.location = "{:U('Statistics/index',$formget)}";
			}
		}
		setInterval(function() {
			refersh_window();
		}, 2000);
		$(function() {
			setCookie("refersh_time", 0);
			Wind.use('ajaxForm', 'artDialog', 'iframeTools', function() {
				//批量移动
				$('.J_articles_move').click(
						function(e) {
							var str = 0;
							var id = tag = '';
							$("input[name='ids[]']").each(function() {
								if ($(this).attr('checked')) {
									str = 1;
									id += tag + $(this).val();
									tag = ',';
								}
							});
							if (str == 0) {
								art.dialog.through({
									id : 'error',
									icon : 'error',
									content : '您没有勾选信息，无法进行操作！',
									cancelVal : '关闭',
									cancel : true
								});
								return false;
							}
							var $this = $(this);
							art.dialog.open(
							
										"{:U('Statistics/move',array('ids'=> ''))}"
											+ id, {
										title : "移动分类",
										width : "40%"
									});
						});
			});
		});
$('.emoji').emoji();
	</script>
</body>
</html>